package com.test.exam.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class AdminSessionInterceptor extends HandlerInterceptorAdapter {
	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		
	//	System.out.println("AdminSessionInterceptor실행");
		HttpSession session = request.getSession();
		
		if(session.getAttribute("isAdmin") == null
			|| (Boolean)session.getAttribute("isAdmin")!=true){
			response.sendRedirect("/");
	//		System.out.println("AdminSessionInterceptor if문");
			return false;
		}
		
		return super.preHandle(request, response, handler);
	}
}

